package cn.itcast.service.packing.impl;

import cn.itcast.dao.packing.FinanceDao;
import cn.itcast.domain.packing.Finance;
import cn.itcast.domain.packing.FinanceExample;
import cn.itcast.service.packing.FinanceService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class FinanceServiceImpl implements FinanceService {

    @Autowired
    FinanceDao financeDao;

    @Override
    public List<Finance> findAll(FinanceExample example) {
        return financeDao.selectByExample(example);
    }

    @Override
    public Finance findById(String id) {
        return financeDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(Finance finance) {
        financeDao.insertSelective(finance);
    }

    @Override
    public void update(Finance finance) {
        financeDao.updateByPrimaryKeySelective(finance);
    }

    @Override
    public void delete(String id) {
financeDao.deleteByPrimaryKey(id);
    }

    @Override
    public PageInfo findByPage(int pageNum, int pageSize, FinanceExample example) {
        PageHelper.startPage(pageNum,pageSize);
        List<Finance> financeList = financeDao.selectByExample(example);

        return new PageInfo(financeList);
    }
}
